package lab01;

public class Test05 {
    public static void main(String[] args) {
        int i;
        int sum;
        //用for循环求和
        sum = 0;
        for (i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println("for:" + sum);
        //用while循环求和
        int n = 1;
        sum = 0;
        while (n <= 100) {
            sum += n;
            n++;
        }
        System.out.println("while:" + sum);
        //用do...whlie循环求和
        int m = 1;
        sum = 0;
        do {
            sum += m;
            m++;
        } while (m <= 100);
        System.out.println("do...while:" + sum);
    }
}